import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:new_yuqib_app/yqbConfig/custom_button.dart';
import 'package:new_yuqib_app/yqbConfig/custom_font_style.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';

import 'controller.dart';

///意见反馈
class FeedbackPage extends StatelessWidget {
  const FeedbackPage({super.key});

  @override
  Widget build(BuildContext context) {
    final controller = Get.put(FeedbackController());
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: (){
        FocusScope.of(context).unfocus();
      },
      child: Scaffold(
        appBar: AppBar(
          leading: const CupertinoNavigationBarBackButton(color: Colors.black),
          title: const Text('关于我们'),
          centerTitle: true,
        ),
        backgroundColor: Colors.white,
        resizeToAvoidBottomInset: false,
        body: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              TextField(
                maxLength: 500,
                maxLines: 5,
                controller: controller.controller,
                decoration: InputDecoration(
                  hintText: "留下您宝贵的意见或者建议",
                  hintStyle: CustomFontStyle.defaultStyle(size: 16, color: const Color(0XFF999999)),
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(4),
                    borderSide: const BorderSide(color: Color(0XFFEFEFEF), width: 1),
                  ),
                  enabledBorder: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(4),
                    borderSide: const BorderSide(color: Color(0XFFEFEFEF), width: 1),
                  ),
                ),
              ),
              Visibility(
                visible: true,
                child: SizedBox(
                  width: double.maxFinite,
                  child: Obx(() {
                    return Wrap(
                      direction: Axis.horizontal,
                      crossAxisAlignment: WrapCrossAlignment.start,
                      alignment: WrapAlignment.start,
                      spacing: 12,
                      runSpacing: 10,
                      children: [
                        for (final item in controller.uploadImages)
                          Stack(
                            alignment: Alignment.topRight,
                            children: [
                              ClipRRect(borderRadius: BorderRadius.circular(10), child: AssetEntityImage(item, width: 100, height: 100, fit: BoxFit.fill)),
                              InkWell(
                                onTap: () {
                                  controller.uploadImages.remove(item);
                                },
                                child: const Icon(
                                  Icons.highlight_remove_rounded,
                                  color: Colors.white,
                                ),
                              ),
                            ],
                          ),
                        Visibility(
                          visible: controller.uploadImages.length < 9,
                          child: InkWell(
                            onTap: controller.showAgreementDialog,
                            child: Container(
                              width: 100,
                              height: 100,
                              alignment: Alignment.center,
                              decoration: BoxDecoration(
                                border: Border.all(width: 1, color: const Color(0XFFEFEFEF)),
                                borderRadius: BorderRadius.circular(5),
                              ),
                              child: const Icon(
                                Icons.add,
                                color: Color(0XFF999999),
                              ),
                            ),
                          ),
                        ),
                      ],
                    );
                  }),
                ),
              ),
              const Expanded(child: SizedBox()),
              CustomButton.radiusButton(
                onTap: controller.imageFileUpload,
                text: "提交",
                height: 48,
                borderRadius: BorderRadius.circular(4),
                color: const Color(0XFFFFB413),
                style: CustomFontStyle.defaultStyle(
                  size: 18,
                  color: Colors.white,
                ),
              ),
              const SizedBox(height: 100),
            ],
          ),
        ),
      ),
    );
  }
}
